﻿using helper.Commons.KnownBoxes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Media;

namespace ZuesControls.Helpers
{
    public  class ControlHelper
    {
        /// <summary>
        /// 图像资源
        /// </summary>
        public static readonly DependencyProperty ImageDataProperty =
            DependencyProperty.RegisterAttached(
                "ImageData",
                typeof(ImageSource),
                typeof(ControlHelper),
                new PropertyMetadata(null));
        public static ImageSource GetImageData(DependencyObject obj)
        {
            return (ImageSource)obj.GetValue(ImageDataProperty);
        }

        public static void SetImageData(DependencyObject obj, ImageSource value)
        {
            obj.SetValue(ImageDataProperty, value);
        }



        public static readonly DependencyProperty PlacementProperty =
           DependencyProperty.RegisterAttached(
               "Placement",
               typeof(PlacementMode),
               typeof(ControlHelper),
               new PropertyMetadata(PlacementMode.Right));
        public static PlacementMode GetPlacement(DependencyObject obj)
        {
            return (PlacementMode)obj.GetValue(PlacementProperty);
        }

        public static void SetPlacement(DependencyObject obj, PlacementMode value)
        {
            obj.SetValue(PlacementProperty, value);
        }


        /// <summary>
        /// 聚焦颜色
        /// </summary>
        public static readonly DependencyProperty FocusedBrushProperty = DependencyProperty.RegisterAttached(
            "FocusedBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush)));

        /// <summary>
        /// Sets the focused brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="value">The value.</param>
        public static void SetFocusedBrush(DependencyObject element, Brush value)
        {
            element.SetValue(FocusedBrushProperty, value);
        }

        /// <summary>
        /// Gets the focused brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>A Brush.</returns>
        public static Brush GetFocusedBrush(DependencyObject element)
        {
            return (Brush)element.GetValue(FocusedBrushProperty);
        }

        /// <summary>
        /// 聚焦前景色
        /// </summary>
        public static readonly DependencyProperty FocusedForegroundBrushProperty = DependencyProperty.RegisterAttached(
            "FocusedForegroundBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush)));

        /// <summary>
        /// Sets the focused foreground brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="value">The value.</param>
        public static void SetFocusedForegroundBrush(DependencyObject element, Brush value)
        {
            element.SetValue(FocusedForegroundBrushProperty, value);
        }

        /// <summary>
        /// Gets the focused foreground brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>A Brush.</returns>
        public static Brush GetFocusedForegroundBrush(DependencyObject element)
        {
            return (Brush)element.GetValue(FocusedForegroundBrushProperty);
        }

        /// <summary>
        /// 聚焦边框颜色
        /// </summary>
        public static readonly DependencyProperty FocusBorderBrushProperty = DependencyProperty.RegisterAttached(
             "FocusBorderBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush)));

        /// <summary>
        /// Sets the focus border brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="value">The value.</param>
        public static void SetFocusBorderBrush(DependencyObject element, Brush value)
        {
            element.SetValue(FocusBorderBrushProperty, value);
        }

        /// <summary>
        /// Gets the focus border brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>A Brush.</returns>
        public static Brush GetFocusBorderBrush(DependencyObject element)
        {
            return (Brush)element.GetValue(FocusBorderBrushProperty);
        }

        /// <summary>
        /// 聚焦边框厚度
        /// </summary>
        public static readonly DependencyProperty FocusBorderThicknessProperty = DependencyProperty.RegisterAttached(
            "FocusBorderThickness", typeof(Thickness), typeof(ControlHelper), new PropertyMetadata(default(Thickness)));

        /// <summary>
        /// Sets the focus border thickness.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="value">The value.</param>
        public static void SetFocusBorderThickness(DependencyObject element, Thickness value)
        {
            element.SetValue(FocusBorderThicknessProperty, value);
        }

        /// <summary>
        /// Gets the focus border thickness.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>A Thickness.</returns>
        public static Thickness GetFocusBorderThickness(DependencyObject element)
        {
            return (Thickness)element.GetValue(FocusBorderThicknessProperty);
        }

        /// <summary>
        /// 鼠标悬停颜色
        /// </summary>
        public static readonly DependencyProperty MouseOverBrushProperty = DependencyProperty.RegisterAttached(
            "MouseOverBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush)));

        /// <summary>
        /// Sets the mouse over brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="value">The value.</param>
        public static void SetMouseOverBrush(DependencyObject element, Brush value)
        {
            element.SetValue(MouseOverBrushProperty, value);
        }

        /// <summary>
        /// Gets the mouse over brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>A Brush.</returns>
        public static Brush GetMouseOverBrush(DependencyObject element)
        {
            return (Brush)element.GetValue(MouseOverBrushProperty);
        }

        /// <summary>
        /// 按下颜色
        /// </summary>
        public static readonly DependencyProperty PressedBrushProperty = DependencyProperty.RegisterAttached(
           "PressedBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush)));

        /// <summary>
        /// Sets the pressed brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="value">The value.</param>
        public static void SetPressedBrush(DependencyObject element, Brush value)
        {
            element.SetValue(PressedBrushProperty, value);
        }

        /// <summary>
        /// Gets the pressed brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>A Brush.</returns>
        public static Brush GetPressedBrush(DependencyObject element)
        {
            return (Brush)element.GetValue(PressedBrushProperty);
        }

        /// <summary>
        /// 选中颜色
        /// </summary>
        public static readonly DependencyProperty SelectedBrushProperty = DependencyProperty.RegisterAttached(
           "SelectedBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush)));

        /// <summary>
        /// Sets the Selected brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="value">The value.</param>
        public static void SetSelectedBrush(DependencyObject element, Brush value)
        {
            element.SetValue(SelectedBrushProperty, value);
        }

        /// <summary>
        /// Gets the Selected brush.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>A Brush.</returns>
        public static Brush GetSelectedBrush(DependencyObject element)
        {
            return (Brush)element.GetValue(SelectedBrushProperty);
        }

        /// <summary>
        /// 是否聚焦
        /// </summary>
        public static readonly DependencyProperty IsKeyBoardFocusedProperty = DependencyProperty.RegisterAttached(
            "IsKeyBoardFocused", typeof(bool), typeof(ControlHelper), new PropertyMetadata(BooleanBoxes.FalseBox));

        /// <summary>
        /// Gets the is key board focused.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns>A bool.</returns>
        public static bool GetIsKeyBoardFocused(DependencyObject obj)
        {
            return (bool)obj.GetValue(IsKeyBoardFocusedProperty);
        }

        /// <summary>
        /// Sets the is key board focused.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="value">If true, value.</param>
        public static void SetIsKeyBoardFocused(DependencyObject obj, bool value)
        {
            obj.SetValue(IsKeyBoardFocusedProperty, BooleanBoxes.Box(value));
        }

        /// <summary>
        /// 遮罩透明度
        /// </summary>
        public static readonly DependencyProperty MaskOpacityProperty = DependencyProperty.RegisterAttached(
            "MaskOpacity", typeof(double), typeof(ControlHelper), new PropertyMetadata(0.6));

        /// <summary>
        /// Gets the mask opacity.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns>A double.</returns>
        public static double GetMaskOpacity(DependencyObject obj)
        {
            return (double)obj.GetValue(MaskOpacityProperty);
        }

        /// <summary>
        /// Sets the mask opacity.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="value">The value.</param>
        public static void SetMaskOpacity(DependencyObject obj, double value)
        {
            obj.SetValue(MaskOpacityProperty, value);
        }


        /// <summary>
        /// 这是自定义Pata 路径
        /// </summary>
        public static readonly DependencyProperty IconDataProperty =
            DependencyProperty.RegisterAttached(
                "IconData",
                typeof(DrawingImage),
                typeof(ControlHelper),
                new PropertyMetadata(null));
        public static DrawingImage GetIconData(DependencyObject obj)
        {
            return (DrawingImage)obj.GetValue(IconDataProperty);
        }

        public static void SetIconData(DependencyObject obj, DrawingImage value)
        {
            obj.SetValue(IconDataProperty, value);
        }

        /// <summary>
        /// 这是自定义Pata 路径
        /// </summary>
        public static readonly DependencyProperty RSIconDataProperty =
            DependencyProperty.RegisterAttached(
                "RSIconData",
                typeof(Geometry),
                typeof(ControlHelper),
                new PropertyMetadata(null));
        public static Geometry GetRSIconData(DependencyObject obj)
        {
            return (Geometry)obj.GetValue(RSIconDataProperty);
        }

        public static void SetRSIconData(DependencyObject obj, Geometry value)
        {
            obj.SetValue(RSIconDataProperty, value);
        }





        /// <summary>
        /// 这是自定义Pata 路径
        /// </summary>
        public static readonly DependencyProperty ReversalIconDataProperty =
            DependencyProperty.RegisterAttached(
                "ReversalIconData",
                typeof(DrawingImage),
                typeof(ControlHelper),
                new PropertyMetadata(null));
        public static DrawingImage GetReversalIconData(DependencyObject obj)
        {
            return (DrawingImage)obj.GetValue(ReversalIconDataProperty);
        }

        public static void SetReversalIconData(DependencyObject obj, DrawingImage value)
        {
            obj.SetValue(ReversalIconDataProperty, value);
        }


        /// <summary>
        /// 这是Icon宽度
        /// </summary>

        public static readonly DependencyProperty IconWidthProperty =
          DependencyProperty.RegisterAttached(
              "IconWidth",
              typeof(double),
              typeof(ControlHelper),
              new PropertyMetadata(12D));

        public static double GetIconWidth(DependencyObject obj)
        {
            return (double)obj.GetValue(IconWidthProperty);
        }

        public static void SetIconWidth(DependencyObject obj, double value)
        {
            obj.SetValue(IconWidthProperty, value);
        }


        /// <summary>
        /// 这是Icon高度
        /// </summary>
        public static readonly DependencyProperty IconHeightProperty =
          DependencyProperty.RegisterAttached(
              "IconHeight",
              typeof(double),
              typeof(ControlHelper),
              new PropertyMetadata(12D));

        public static double GetIconHeight(DependencyObject obj)
        {
            return (double)obj.GetValue(IconHeightProperty);
        }

        public static void SetIconHeight(DependencyObject obj, double value)
        {
            obj.SetValue(IconHeightProperty, value);
        }


        public static readonly DependencyProperty TreeLevelProperty =
          DependencyProperty.RegisterAttached(
              "TreeLevel",
              typeof(int),
              typeof(ControlHelper),
              new PropertyMetadata(0));

        public static int GetTreeLevel(DependencyObject obj)
        {
            return (int)obj.GetValue(TreeLevelProperty);
        }

        public static void SetTreeLevel(DependencyObject obj, int value)
        {
            obj.SetValue(TreeLevelProperty, value);
        }

        /// <summary>
        /// 设置控件圆角
        /// </summary>
        public static readonly DependencyProperty CornerRadiusProperty =
          DependencyProperty.RegisterAttached(
              "CornerRadius",
              typeof(CornerRadius),
              typeof(ControlHelper),
              new PropertyMetadata(default));

        public static CornerRadius GetCornerRadius(DependencyObject obj)
        {
            return (CornerRadius)obj.GetValue(CornerRadiusProperty);
        }

        public static void SetCornerRadius(DependencyObject obj, CornerRadius value)
        {
            obj.SetValue(CornerRadiusProperty, value);
        }

        /// <summary>
        /// 控件外层背景颜色
        /// </summary>
        public static readonly DependencyProperty OutLevelBackgroundProperty =
            DependencyProperty.RegisterAttached(
                "OutLevelBackground",
                typeof(Brush),  // 修正为Brush类型，用于设置背景颜色
                typeof(ControlHelper),
                new PropertyMetadata(default(Brush)));  // 指定默认值类型为Brush

        public static Brush GetOutLevelBackground(DependencyObject obj)
        {
            return (Brush)obj.GetValue(OutLevelBackgroundProperty);
        }

        public static void SetOutLevelBackground(DependencyObject obj, Brush value)
        {
            obj.SetValue(OutLevelBackgroundProperty, value);
        }

        /// <summary>
        /// 控件中层背景颜色
        /// </summary>
        public static readonly DependencyProperty MiddleLevelBackgroundProperty =
            DependencyProperty.RegisterAttached(
                "MiddleLevelBackground",
                typeof(Brush),  // 修正为Brush类型，用于设置背景颜色
                typeof(ControlHelper),
                new PropertyMetadata(default(Brush)));  // 指定默认值类型为Brush

        public static Brush GetMiddleLevelBackground(DependencyObject obj)
        {
            return (Brush)obj.GetValue(MiddleLevelBackgroundProperty);
        }

        public static void SetMiddleLevelBackground(DependencyObject obj, Brush value)
        {
            obj.SetValue(MiddleLevelBackgroundProperty, value);
        }

        /// <summary>
        /// 控件内层背景颜色
        /// </summary>
        public static readonly DependencyProperty InLevelBackgroundProperty =
            DependencyProperty.RegisterAttached(
                "InLevelBackground",
                typeof(Brush),  // 修正为Brush类型，用于设置背景颜色
                typeof(ControlHelper),
                new PropertyMetadata(default(Brush)));  // 指定默认值类型为Brush

     
        public static Brush GetInLevelBackground(DependencyObject obj)
        {
            return (Brush)obj.GetValue(InLevelBackgroundProperty);
        }

        public static void SetInLevelBackground(DependencyObject obj, Brush value)
        {
            obj.SetValue(InLevelBackgroundProperty, value);
        }
        #region 必填选项设置

        public static readonly DependencyProperty IsRequiredProperty =
  DependencyProperty.RegisterAttached("IsRequired", typeof(bool), typeof(ControlHelper), new PropertyMetadata(false));

        public static bool GetIsRequired(UIElement element)
        {
            return (bool)element.GetValue(IsRequiredProperty);
        }
        public static void SetIsRequired(UIElement element, bool value)
        {
            element.SetValue(IsRequiredProperty, value);
        }
        #endregion

        #region 选中颜色

        public static readonly DependencyProperty SelectedBackgroundProperty = DependencyProperty.RegisterAttached(
                 "SelectedBackground",
                 typeof(Brush),
                 typeof(ControlHelper),
                 new FrameworkPropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EEE"))));

        public static Brush GetSelectedBackground(UIElement element)
        {
            return (Brush)element.GetValue(SelectedBackgroundProperty);
        }

        public static void SetSelectedBackground(UIElement element, Brush value)
        {
            element.SetValue(SelectedBackgroundProperty, value);
        }
        #endregion

        public static readonly DependencyProperty BlendRatioProperty =
           DependencyProperty.RegisterAttached(
               "BlendRatio",
               typeof(double),
               typeof(ControlHelper),
               new PropertyMetadata(0D));

        public static void SetBlendRatio(UIElement element, double value)
        {
            element.SetValue(BlendRatioProperty, value);
        }

        public static double GetBlendRatio(UIElement element)
        {
            return (double)element.GetValue(BlendRatioProperty);
        }

        /// <summary>
        /// 这是Icon高度
        /// </summary>
        public static readonly DependencyProperty DescriptionProperty =
          DependencyProperty.RegisterAttached(
              "Description",
              typeof(string),
              typeof(ControlHelper),
              new PropertyMetadata(""));

        public static double GetDescription(DependencyObject obj)
        {
            return (double)obj.GetValue(DescriptionProperty);
        }

        public static void SetDescription(DependencyObject obj, double value)
        {
            obj.SetValue(DescriptionProperty, value);
        }

        #region 滑条颜色
        public static readonly DependencyProperty ScrollBarBackgroundProperty =
                   DependencyProperty.RegisterAttached(
                       "ScrollBarBackground",
                       typeof(Brush),
                       typeof(ControlHelper),
                       new PropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#646365"))));

        public static Brush GetScrollBarBackground(DependencyObject obj)
        {
            return (Brush)obj.GetValue(ScrollBarBackgroundProperty);

        }

        public static void SetScrollBarBackground(DependencyObject obj, Brush value)
        {
            obj.SetValue(ScrollBarBackgroundProperty, value);
        }

        public static readonly DependencyProperty DesForegroundProperty = DependencyProperty.RegisterAttached(
      "DesForeground",
      typeof(Brush),
      typeof(ControlHelper),
      new FrameworkPropertyMetadata(null));

        public static Brush GetDesForeground(UIElement element)
        {
            return (Brush)element.GetValue(DesForegroundProperty);
        }

        public static void SetDesForeground(UIElement element, Brush value)
        {
            element.SetValue(DesForegroundProperty, value);
        }

     
        #endregion
    }
}
